#include "mygraphicsscene.h"
#include <QDebug>
#include <QUrl>
#include <QMimeData>
#include <QImage>

MyGraphicsScene::MyGraphicsScene(QObject *parent) :
    QGraphicsScene(parent)
{
    movingItem = 0;
}

void MyGraphicsScene::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
{
    if (event->mimeData()->urls().count() != 1)
    {
        event->ignore();
    }
    QString str = event->mimeData()->urls().first().toLocalFile();
    QImage image;
    if (!image.load(str))
    {
        event->ignore();
    }
}

void MyGraphicsScene::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
{
}

void MyGraphicsScene::dropEvent(QGraphicsSceneDragDropEvent *event)
{
    QString str = event->mimeData()->urls().first().toLocalFile();
    emit dragFileSignal(str);
}

void MyGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
    QGraphicsScene::mousePressEvent(event);
}

void MyGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
    QGraphicsScene::mouseReleaseEvent(event);
}
